﻿#ifdef USEJNI
#include "JNIUtil.h"
namespace yzrilyzr_util {
	template <typename T>
	Array<T>* jArray2WithLength(JNIEnv* env, jlongArray jd) {
		jlong* elements = env->GetLongArrayElements(jd, nullptr);
		int32_t length = env->GetArrayLength(jd);
		if (elements == nullptr) {
			std::cerr << "Buffer nullptr" << std::endl;
			return nullptr;
		}
		Array<T>* dl = new Array<T>(length);
		for (int32_t i = 0; i < length; i++) {
			(*dl)[i] = reinterpret_cast<T*>(elements[i]);
		}
		env->ReleaseLongArrayElements(jd, elements, 0);
		return dl;
	}
}
#endif